package org.huawei260.TiKu.ODsuanfa;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
public class E_2024E_3203__不定滑窗_寻找符合要求的最长子串 {

//	public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);

			String s1 = sc.nextLine();
			String s2 = sc.nextLine();

			System.out.println(getResult(s1, s2));
		}

		public static String getResult(String s1, String s2) {
			HashSet<Character> set1 = new HashSet<>();
			for (char c : s1.toCharArray()) set1.add(c);

			HashSet<Character> set2 = new HashSet<>();
			for (char c : s2.toCharArray()) set2.add(c);

			Character[] characters = set1.stream().filter(c -> set2.contains(c)).toArray(Character[]::new);
			Arrays.sort(characters);

			StringBuilder sb = new StringBuilder();
			for (Character c : characters) sb.append(c);

			return sb.toString();
		}
	}